<?php
include("../../config/connect.php");
require_once("../../public/common.php");

// 更新cache数据
date_default_timezone_set("Asia/Chongqing");
require_once("../../taobaoapi/funs.php");

//
$sql = "select id from cache_items order by id desc limit 1";
$result = mysql_query( $sql );
if (mysql_num_rows($result) > 0)
{
	$row = mysql_fetch_assoc( $result );
	$idbase = $row["id"];
}
else
	$idbase = 1;
	
$sql = "select id,outer_code,pay_time,real_pay_fee,num_iid,item_title,commission from report_items where id > $idbase and commission > 3.0 and outer_code<>'' order by id limit 10";
$result = mysql_query( $sql );
while( $result && $row = mysql_fetch_assoc( $result ))
{
	$json = json_decode(GetItemInfo($row["num_iid"]));
	if ($json->code == 1)
	{
	 	$pic_url = $json->pic_url;
		$url = $json->detail_url;
		if ($pic_url != "")
		{
			$sql = "insert into cache_items (id, user_id,time, fee, num_iid, item_title, commission, pic_url, url) values 
			(".$row["id"].",".$row["outer_code"].",'".$row["pay_time"]."',".$row["real_pay_fee"].",'".$row["num_iid"]."','".$row["item_title"]."',".$row["commission"].",'$pic_url','$url')";
			mysql_query( $sql );
//			if (mysql_affected_rows() > 0)
//				$nHasInsert++;
		}
	}
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://www.gouwutu.com/n2/v2/css/nav/jquery.js"></script>
<script type="text/javascript" src="http://www.gouwutu.com/v2/php/jQuery.textSlider.js"></script>
<style type="text/css">
body, div, dl, dt, dd, ul, ol, li, p, h1, h2, h3, h4, h5, h6, form, fieldset, legend, input, textarea, blockquote, th, td{margin: 0;padding: 0;}
ul,li,img{margin:0;padding:0; list-style:none; border:0; vertical-align:top;}
table,tr,th,td {border-collapse: collapse;border-spacing: 0;font-size: 12px;}
#newFanxian .newText { width:948px; height:244px; overflow:hidden;}
#newFanxian ul li { height:244px;}
#newFanxian ul a { width:948px; height:60px; display:block; overflow:hidden; background-color:#fff; border-bottom:1px dashed #ccc;}
#newFanxian ul a:hover { background-color:#fafafa;}
.newText .pic,.newText .title { float:left;}
.newText .title,.newText .nichen { height:60px; line-height:60px; width:290px; overflow:hidden;}
.newText .nichen { width:100px;}
.newText ul li span { color:red;}
 /*伪类事件*/
a:link{color:#777;text-decoration:none;outline:none;cursor:pointer;}
a:visited{color:#777;text-decoration:none;}
a:hover{color:#2287B3;text-decoration:none;}
a:active{color:#777;text-decoration:none;}﻿
</style>
</head>
<body style="margin:0 auto;padding:0; font-size:12px; color:#777; width:948px;">
<div id="newFanxian" style="margin:0;padding:0; width:948px;">
	<div class="newText">
	<ul>
<?PHP
static $i=0;
$sql = "select ca.*,u.tb_id as tbid,u.level as level from cache_items as ca,user as u where ca.user_id=u.id and ca.pic_url<>'' order by ca.time desc limit 24";
$result = mysql_query( $sql );
while( $result && $row = mysql_fetch_assoc( $result ))
{
if($i++%4==0)
{
	echo '<li>';
}
$level = $row["level"];
$levelData = GetTubi($level);
?>
	<a href="http://www.gouwutu.com/new/s/?ref=icbc&id=<?php echo substr($row["url"],35); ?>&q=<?php echo urlencode($row["item_title"]); ?>" target="_blank">
    <table width="948" height="60" cellspacing="0" cellpadding="0" border="0" align="center">
        <tr align="center" style="color:#336081;">
            <td width="80"><?php echo $row["time"]; ?></td>
            <td width="100"><p class="nichen" title="<?php echo $row["tbid"]; ?>"><?PHP echo substr($row["tbid"], 0, 6)."***".substr($row["tbid"], -6); ?></p></td>
            <td width="80"><?PHP echo $levelData["level_desc"] ?></td>
            <td width="360"><img width="60" height="60" title="<?php echo $row["item_title"]; ?>" alt="<?php echo $row["item_title"]; ?>" src="<?PHP echo $row["pic_url"]."_70x70.jpg"; ?>" class="pic"><p class="title" title="<?php echo $row["item_title"]; ?>">&nbsp;<?php echo $row["item_title"]; ?></p></td>
            <td width="100">售价&nbsp;<span><?php echo $row["fee"]; ?></span>&nbsp;元</td>
            <td width="100">获现金&nbsp;<span><?PHP echo round($row["commission"] * 0.6, 2); ?></span>&nbsp;元</td>
            <td width="120" title="攒兔币，换IPhone4，大奖多多哦~">加赠&nbsp;<span><?php echo round(0.6*$row["commission"]*10) ?></span>&nbsp;<img src="http://www.gouwutu.com/dh/images/jin2.gif" alt="兔币" title="兔币"></td>
        </tr>
    </table>
   	</a>

<?PHP 
if ($i % 4 == 0)          
	echo '</li>';
} 

?>
    </li>
    	</ul>
    </div>
</div>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(){
        $("#newFanxian").textSlider({line:1,speed:500,timer:4000});
		/*
		
		 static $count = 0;
   $count++;
   echo $count;
   if ($count < 10) {
   Test();
   }
   $count--;
   }
		
		*/
});
</script>